#ifndef SNAKE_H
#define SNAKE_H
#include <functional>
using std::pair;
#include "ixion.h"

#include <iostream>

class Snake
{
public:
	enum DIRECTION {UP, DOWN, LEFT, RIGHT};
	Snake(int x, int y, DIRECTION init_head = UP);
	~Snake();
	pair<int,int> Head() const;
	void SetHeading(DIRECTION dir);
	void AddSegment(); //adds a segment to the tail
	void Update(); //updates the positions;
	void Draw() const;
	bool CheckForColision() const; //checks if the head touches any segments
	static int MAX_HEIGHT;
	static int  MAX_WIDTH;
	static int  MIN_HEIGHT;
	static int  MIN_WIDTH;
	static char SPRITE_TAIL;
	static char SPRITE_HEAD;
	static bool COLISION;
private:
	
	class Segment
	{
	public:
		Segment():next_segment(NULL) {};
		pair<int, int> cur_pos;
		pair<int, int> old_pos;
		Segment * next_segment;
	};
	unsigned size;
	Segment * head;
	DIRECTION heading;
	void Util_AddSegment(Segment *& root);
	void Util_Update(Segment *& root);
	void Util_Delete(Segment *& root);
};

#endif